local Action_AdjustCard = 
{
    MaxRoundWaitTime = 0;            -- 回合最长等待时长
}

function Action_AdjustCard:Execute()
    self.bEnableActionTick = true

    --UI部分接口,所有玩家显示是否调整卡牌（卡牌按钮和确认按钮）,RPC给所有客户端
    UnrealNetwork.CallUnrealRPC_Multicast(UGCGameSystem.GameState, "Multicast_AdjustCardUI");

    self.EnterStatgeTime = GameplayStatics.GetRealTimeSeconds(self)
    print("Action_AdjustCard:Execute end")
end

--确认调整按钮，获取点击事件，执行逻辑：UI与事件系统处理调整卡牌相关逻辑，调用GameState:AddCard()处理相关逻辑
--并关闭卡牌选择的UI
--然后再更新UI？待商榷，怎么处理卡牌数量UI：参数同步？

--调整卡牌后更新UI，事件是对update检测的优化
function Action_AdjustCard:Update()
    print("Action_AdjustCard:Update")
    local CurrentRealTime = GameplayStatics.GetRealTimeSeconds(self)
    local RemainTime = self.MaxRoundWaitTime - (CurrentRealTime - self.EnterStatgeTime)
    
    --UI显示
    UGCGameSystem.GameState.AdjustRemainTime = RemainTime
    if RemainTime <= 0 then
        self:EndAdjustCardStage();
	end
    
    print("Action_AdjustCard:Update  end")
    -- UI改变属性判断是否全部完成调整卡牌
    -- for i=1,self.PlayerNum do
    --     if not UGCGameSystem.GameState.PlayerInfos[i].HasFinishedAdjustCard then
    --     	return 
    -- 	end
    -- end
    -- print("All Players Have Finished Adjusting Card!")
    -- LuaQuickFireEvent("PlayerStartNewRound", self)
    -- self.bEnableActionTick = false
end

-- 未操作则关闭调整卡牌UI并 自动进行下一回合!!!!!!!!
function Action_AdjustCard:EndAdjustCardStage()
  
    print("Action_AdjustCard:EndAdjustCardStage")
    self.bEnableActionTick = false;

    --再次更新玩家面板，UI显示玩家信息面板,需要吗？？？
    --UnrealNetwork.CallUnrealRPC_Multicast(UGCGameSystem.GameState, "Multicast_PlayerPanel", UGCGameSystem.GameState.PlayerInfos);
    LuaQuickFireEvent("PlayerStartNewRound", self)
end

return Action_AdjustCard